<?php 
	include($_SERVER['DOCUMENT_ROOT']."/headerins.php");
	include($_SERVER['DOCUMENT_ROOT']."/headerFrame.php");

echo '
        <div id="contextCaption">Просморт заказов.</div>
        <hr>
            <table border="0" id="contextGrid" cellspacing="0">
                <thead>
                    <tr>
                       <th>№</th>
                       <th>Продавец</th>
					   <th>Покупатель</th>
					   <th>Дата</th>
					   <th>Описание</th>
					   <th>Изм</th>
					   <th>Уд</th>
                    </tr>
                </thead>
                <tbody>
';

                          $sql = '
								SELECT
									o.id
									,(select lastname  from users where id = o.userID) userID
									,(select lastname from users where id = o.userIDTo) userIDTo
									,o.createDT
									,o.description
								FROM
									`order` o 
                          ';
                          $result = mysql_query($sql);
                            if (!$result) {
                                echo 'Ошибка запроса: ' . mysql_error();
                                exit;
                            }
                          while($row = mysql_fetch_array($result)){
                              echo "<tr>";
                              echo "<td> " .$row['id']. "</td>";
                              echo "<td> " . $row['userID'] . "</td>";                                  
							  echo "<td> " . $row['userIDTo'] . "</td>";
							  echo "<td> " . $row['createDT'] . "</td>";
							  echo "<td> " . $row['description'] . "</td>";

							  echo "<td>  
	<img onclick=".'"'."getPage('/core/Order/OrderUpdate.php?id=".$row['id']."')".'"'." src='/../images/edit.png' alt='Изменить' width=16 height=16> </td>";
                              echo "<td>  
	<img onclick=".'"'."Request('Order','delete', '".$row['id']."')".'"'." src='/../images/delete.png' alt='Удалить' width=16 height=16> </td>";
                              echo "</tr>";
                            }

                          mysql_close($con);
echo '
                </tbody>
            </table>
            <hr>
            <input id="button" type="Button"  value="Закрыть" title="закрыть" onclick="getPage('."'".'/core/context/context.html'."'".')">            
            <input id="button" type="Button" 
			
			onclick="getPage('."'".'/core/Order/OrderCreate.php'."'".')"
			
			value="Создать" title="создать новый заказ">
';

?>
